package edu.base.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageInfo;
import edu.base.util.HigherResponse;
import edu.base.entity.RecordEquipment;
import edu.base.service.RecEqptService;

/**
 * @author 10173
 *
 */
@Controller		
@RequestMapping("/eqpt")
public class RecEqptCon {
	
	@Autowired
	private RecEqptService recEqptService;
	
	//分页查询所有设备
	@ResponseBody
	@RequestMapping("list.do")
	public HigherResponse<PageInfo<RecordEquipment>> queryEqptByPage(@RequestParam(required = true,defaultValue = "1")Integer pageNum,@RequestParam(required = true,defaultValue = "10")Integer pageSize){
		return recEqptService.queryEqptByPage(pageNum, pageSize);
	}
	
	//根据日期和产品类型查询设备
	@ResponseBody
	@RequestMapping("/queryEqptByDate.do")
	public HigherResponse<PageInfo<RecordEquipment>> queryEqptByDate(String beginDate, String endDate,
			Integer prodType, @RequestParam(required = true,defaultValue = "1")Integer pageNum, @RequestParam(required = true,defaultValue = "10")Integer pageSize) {
		return recEqptService.queryEqptByDate(beginDate, endDate, prodType, pageNum, pageSize);
	}
	
	//根据id查询设备信息
	@ResponseBody
	@RequestMapping("/queryEqptById.do")
	public HigherResponse<RecordEquipment> queryEqptById(Integer id) {
		return recEqptService.queryEqptById(id);
	}
	
	//根据id修改设备信息
	@ResponseBody
	@RequestMapping("/updateEqptById.do")
	public HigherResponse<String> updateEqptById(RecordEquipment receqpt) {
		return recEqptService.updateEqptById(receqpt);
	}
	
	//删除设备for real
	@ResponseBody
	@RequestMapping("/deleteOneEqptById.do")
	public HigherResponse<String> deleteOneEqptById(Integer id) {
		return recEqptService.deleteOneEqptById(id);
	}
	
	//删除设备 fake
	@ResponseBody
	@RequestMapping("/deleteEqptById.do")
	public HigherResponse<String> deleteEqptById(Integer id) {
		return recEqptService.deleteEqptById(id);
	}
	
	//添加设备
	@ResponseBody
	@RequestMapping("/insertEqpt.do")
	public HigherResponse<String> insertEqpt(RecordEquipment receqpt) {
		return recEqptService.insertEqpt(receqpt);
	}
	
	//根据报修编号查询设备
	@ResponseBody
	@RequestMapping("/queryEqptByRepId.do")
	public HigherResponse<PageInfo<RecordEquipment>> queryEqptByRepairId(Integer repairId,@RequestParam(required = true,defaultValue = "1") Integer pageNum, @RequestParam(required = true,defaultValue = "5")Integer pageSize) {
		return recEqptService.queryEqptByRepairId(repairId, pageNum, pageSize);
	}
	
	//根据报修id产品类型查询设备
	@ResponseBody
	@RequestMapping("/queryEqptByProdType.do")
	public HigherResponse<PageInfo<RecordEquipment>> queryEqptByProdType(Integer repairId,Integer prodType,
			@RequestParam(required = true,defaultValue = "1")Integer pageNum,@RequestParam(required = true,defaultValue = "5") Integer pageSize) {
		return recEqptService.queryEqptByProdType(repairId, prodType, pageNum, pageSize);
	}
}
